<template>
    <div class="userCenter">
        <div class="breadcrumb-box">
            <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                <el-breadcrumb-item>个人中心</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="center container td-f">
            <left-nav-bar :active="active"></left-nav-bar>
            <div class="right">
                <div class="right-text">{{$route.query.index == 0?'待付账单':'未出账单'}}</div>
                <div class="wait-text">
                    {{$route.query.index == 0?'待付金额':'未出账金额'}}{{price}}元
                </div>
                <el-table :data="list" style="width: 100%">
                    <el-table-column prop="order_id" label="订单编号" width="250">
                    </el-table-column>
                    <el-table-column prop="order_name" label="名称" width="180">
                    </el-table-column>
                    <el-table-column prop="amount" label="金额" width="100">
                    </el-table-column>
                    <el-table-column prop="create_time" label="时间">
                    </el-table-column>
                </el-table>
                <el-pagination background layout="prev, pager, next" :total="count" @current-change="_handelClickPage" :page-size="limit">
                </el-pagination>
                <div class="choose">
                    <div class="green" @click="payMonth">还款</div>
                </div>
            </div>

        </div>
        <div style="height: 200px"></div>
    </div>
</template>

<script>
import leftNavBar from "@components/leftNavBar";
import { cashLog, monthSelf } from "@/api/public";
export default {
    data() {
        return {
            page: 1,
            limit: 10,
            price: 0,
            list: [],
        };
    },
    components: {
        "left-nav-bar": leftNavBar,
    },
    methods: {
        payMonth(){
            if(this.price){
this.$router.push({
                path: "/payMonth",
            });
            }else{
                this.$dialog.error(  "您无需再进行支付" );
            }
            
        },
        _handelClickPage(e) {
            this.page = e;
            this.getList();
        },
        monthSelfs() {
            let data = {
                paid: this.$route.query.index == 0 ? 1 : 0,
            };
            monthSelf(data)
                .then((res) => {
                    console.log(res);
                    this.price = res.data.price;
                })
                .catch((err) => {});
        },
        getList() {
            let data = {
                page: this.page,
                limit: this.limit,
                paid: this.$route.query.index == 0 ? 1 : 0,
            };
            cashLog(data)
                .then((res) => {
                    console.log(res);
                    this.list = res.data.list;
                    this.count = res.data.count;
                })
                .catch((err) => {});
        },
    },
    mounted() {
        this.getList();
        this.monthSelfs();
    },
};
</script>
<style lang="scss">
.el-pagination {
    display: flex;
    justify-content: center;
    margin: 10px 0;
}
.el-pagination.is-background .el-pager li:not(.disabled).active {
    background: #da213d;
}
</style>
<style lang="scss" scoped>
.right {
    flex: 1;
    margin-left: 10px;
    .choose {
        margin-top: 136px;
        .green {
            cursor: pointer;
            width: 230px;
            height: 50px;
            background: #45b39c;
            border-radius: 5px;
            font-size: 18px;
            font-weight: bold;
            text-align: center;
            color: #ffffff;
            line-height: 50px;
            margin: 0 auto;
        }
    }
    .right-text {
        font-size: 18px;
        border: 1px solid #666;
        width: 200px;
        height: 50px;
        text-align: center;
        line-height: 50px;
        color: #666;
        border-radius: 5px;
        margin: 0 auto;
    }
    .wait-text {
        margin: 0 auto;
        font-size: 18px;
        color: #666;
        line-height: 50px;
        width: 200px;
        text-align: center;
    }
}
</style>